package com.xcf.cloud.mailsvc.controller;

import com.xcf.cloud.mailsvc.EmailConstant;
import com.xcf.cloud.mailsvc.service.IEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaocf
 */
@RestController
@RequestMapping(EmailConstant.SERVICE_CONTEXT_PATH)
public class EmailController {

    @Autowired
    private IEmailService emailService;

    /**
     * 发送验证码到邮箱，true成功，false失败
     *
     * @param email 邮箱地址
     * @param code  验证码
     * @return true成功，false失败
     */
    @GetMapping(EmailConstant.Path.SEND_MAIL)
    public boolean sendMail(@PathVariable("email") String email, @PathVariable("code") String code) {
        return emailService.sendEmail(email, code);
    }
}
